package cn.wolfcode.mq._03_send_filter;

import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class SendFilterController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("/sendFilterMsg")
    public String sendFilterMsg(String msg,String tag){
        rocketMQTemplate.syncSend("04_filter:"+tag,msg);
        return "success";
    }

    @RequestMapping("/sendFilterMsg2")
    public String sendFilterMsg2(String msg,String tag,String key){
        Map<String,Object> map = new HashMap<>();
        map.put("age",20);
        map.put("name","xxx");
        map.put(MessageConst.PROPERTY_KEYS,key);
        rocketMQTemplate.convertAndSend("04_filter:"+tag,msg,map);
        return "success";
    }
}
